﻿using System.ComponentModel;
using CI.Models.Data;
using CI.Models.Production.Interfaces;

namespace CI.Models.Production
{
    public class IndustryProduct : ModelBase, IIndustryProduct
    {
        private Item _item;

        private IQuantityCalculator<int> _quantity;

        private IIndustryProductConsumption _consumption;

        private int _total;

        public IndustryProduct(Item item, IQuantityCalculator<int> quantity)
        {
            Item = item;
            Quantity = quantity;

            Quantity.PropertyChanged += Quantity_PropertyChanged;
        }

        private void Quantity_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Total")
            {
                SetField(ref _total, Quantity.Total, () => Total);
            }
        }

        public int Total
        {
            get { return _total; }
            set { Quantity.Total = value; }
        }

        public Item Item
        {
            get { return _item; }
            internal set { SetField(ref _item, value, () => Item); }
        }

        public IQuantityCalculator<int> Quantity
        {
            get { return _quantity; }
            internal set { SetField(ref _quantity, value, () => Quantity); }
        }

    }
}